layui.config({
    base: '../../layui/' //此处路径请自行处理, 可以使用绝对路径
}).extend({
    formSelects: 'formSelects-v4'
}).use(['jquery', 'formSelects', 'form','layer'], function () {
    const form = layui.form
        , layer = layui.layer
        , $ = layui.jquery;
    form.on('submit(save)', function (data) {
        const params = data.field;
        submit($, params);
        return false;

    });
    function submit($, params) {
        $.ajax({
            url: '/admDb',
            data: JSON.stringify(params),
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            type: "put",
            success: function (result) {
                if (result.code=200){
                    layer.msg(result.desc, {icon: 1, time: 1000}, function () {
                        CloseWin();
                    })
                }else {
                    layer.msg(result.desc, {icon: 1, time: 1000}, function () {
                        CloseWin();
                    })
                }

            }
        })
    }
    $("#close").on('click', function () {
        const index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    });
    //关闭页面
    function CloseWin() {
        parent.location.reload(); // 父页面刷新
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

});


